function greaterThan(num)
{
	return function(test)
	{
		return num > test;
	}
}

var greaterThan3 = greaterThan(3);
alert(greaterThan3(2));

alert("hello", "good evenging", "how do you do?", "goodbye");

/*
function makeAddFunc(amount)
{
	return function(number)
	{
		return number + amount;
	}
}

var addTwo = makeAddFunc(2);
alert(addTwo(5));
*/
/*
var add = function(a,b)
{
	return a+b;
}
alert(add(5,5));
*/
/*
alert("The future says: ", future());

function future()
{
	return "We still have no flying cars.";
}*/

/*
function findSequence(goal) {
  function find(start, history) {
    if (start == goal)
      return history;
    else if (start > goal)
      return null;
    else
      return find(start + 5, "(" + history + " + 5)") ||
             find(start * 3, "(" + history + " * 3)");
  }
  return find(1, "1");
}
alert(findSequence(24));
*/
/*
function findSequence(goal)
{
	function find(start, history)
	{
		if (start == goal)
		{
			return history;			
		}
		else if( start > goal)
		{
			return null;
		}
		else
		{
			return find(start + 5, "(" + history + " + 5)") || 
				   find(start * 3, "(" + history + " * 3)");
		}		
	}
	return find(1, "1");
}
alert(findSequence(24));
*/


/*
function Power(base, exp)
{
	if(exp == 0) 
	{
		return 1;
	}
	else
	{
		return base * Power(base, exp - 1);
	}
}

alert(Power(10, 3));
*/


/*
//closure return a function and context
function makeAddFunc(amout)
{
	function add(num)
	{
		return amout + num;
	}
	return add;
}
var addTwo = makeAddFunc(2);
var addFive = makeAddFunc(5);
alert(addTwo(1) + addFive(1));
* /

/*
var variable = "top-level";
function parentFunc()
{
	var variable = "local-level";
	function childFunc()
	{
		alert(variable);
	}
	return childFunc;
}

child = parentFunc();
child();
* /

/*
//function is the only thing that create scope
var sth = 1;
{
	var sth = 2;
	alert(sth);
}
alert(sth);
*/

/*
var variable = "top-level";
function parentFunc()
{
	variable = "local-level";
	function childFunc()
	{
		alert(variable);
	}
	childFunc();
}
parentFunc();
* /

/*
var variable = "top-level";
function printVariable()
{
	alert("inside printVariable" + variable + ".");
}
function test()
{
	var variable = "local";
	alert("inside test, the variable holds" + variable + ".");
	printVariable();
}
test();
*/

/*
function add(a,b)
{
	return a + b;
}
function power(base, exp)
{
	var result = 1;
	for(var ct = 0; ct<exp; ct++)
	{
		result *= base;
	}
	return result;
}
function abs(val)
{
	if (val >= 0)
		return val;
	else
		return -val;
}

alert(abs(-23));
*/
